<div class="panel-body">
    <div class="table-responsive">
        <div class="dataTables_wrapper form-inline" id="dataTables-example_wrapper" role="grid">
            <div class="row" style="padding-bottom: 15px">
                <div class="col-sm-6">

                </div>
                <div class="col-sm-6">
                    <div class="dataTables_filter" id="dataTables-example_filter" style="float: right">
                        <a class="btn btn-serch" onclick="Toexcel()">导 出 </a>
                    </div>
                </div>
            </div>
            <table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example"
                   aria-describedby="dataTables-example_info">
                <thead>
                <tr role="row" id="title">
                </tr>
                </thead>
                <tbody id="shoplist">

                </tbody>
            </table>
            <div class="row">
                <div id="page" style="float: right"></div>
            </div>
        </div>
    </div>
    <input type="hidden" id="id"/>
</div>
<script>
    //请求列表
    function setTable(ID) {
        $.ajax({
            type: 'get', //请求的类型
            url: GLOBAL.URL + "/chartinfo/table?id=" + ID,//请求的地址
            dataType: "json", //返会值的类型
            async: false,
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
            success: function (datas, textStatus) {
                var data=datas.data;
                if (datas.code == 0) {
                    var titlestr = "";
                    titlestr += '<th tabindex="0" class="sorting" aria-controls="dataTables-example" style="text-align: center;width: 5%;" rowspan="1" colspan="1">序号</th>';
                    for (var i = 0; i < data.title.length; i++) {
                        titlestr += '<th tabindex="0" class="sorting" aria-controls="dataTables-example" style="text-align: center;width: 5%;" rowspan="1" colspan="1">' + data.title[i] + '</th>';
                    }
                    var datastr = "";
                    for (var k = 0; k < data.data.length; k++) {
                        datastr += '<tr class="gradeA odd"><td style="text-align: center">' + (k + 1) + '</td>';
                        for (var m = 0; m<data.data[k].length; m++) {
                            datastr += '<td style="text-align: center">' + data.data[k][m] + '</td>';
                        }
                        datastr += '</tr>';
                    }
                    $("#title").html(titlestr);
                    $("#shoplist").html(datastr);
                } else {
                    var msg = datas.msg == null ? "" : datas.msg;
                    AlertInfo("请求失败！" + msg);
                }
            }
        })
    }
    
    function Toexcel() {
        var id=$("#id").val();
        window.open(GLOBAL.URL +'/chartinfo/download?id='+id);
    }

</script>